Micron Document
`:top
In `F33f`_`[computing`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computing]`_`f, `!static dispatch`! is a form of `F33f`_`[polymorphism`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Polymorphism_(computer_science)]`_`f fully resolved during `F33f`_`[compile time`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Compile_time]`_`f. It is a form of `*method dispatch,`* which describes how a language or environment will select which implementation of a method or function to use.`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f]

Examples are `F33f`_`[templates in C++`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Template_(C++)]`_`f, and `F33f`_`[generic programming`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Generic_programming]`_`f in `F33f`_`[Fortran`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Fortran]`_`f and other languages, in conjunction with `F33f`_`[function overloading`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Function_overloading]`_`f (including `F33f`_`[operator overloading`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Operator_overloading]`_`f). Code is said to be `F33f`_`[monomorphised`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Monomorphism_(computer_science)]`_`f, with specific `F33f`_`[data types`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Data_type]`_`f deduced and traced through the `F33f`_`[call graph`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Call_graph]`_`f, in order to instantiate specific versions of `F33f`_`[generic functions`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Generic_function]`_`f, and select specific function calls based on the supplied definitions.

This contrasts with `F33f`_`[dynamic dispatch`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Dynamic_dispatch]`_`f, which is based on runtime information (such as `F33f`_`[vtable`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Vtable]`_`f pointers and other forms of run time type information).

Static dispatch is possible because there is a guarantee of there only ever being a single implementation of the method in question. Static dispatch is typically faster than dynamic dispatch which by nature has higher overhead.

>>Contents

• `F0af`_`[Example in Rust`#example-in-rust]`_`f
• `F0af`_`[See also`#see-also]`_`f
• `F0af`_`[References`#references]`_`f

-─

>>Example in Rust

In `F33f`_`[Rust`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Rust_(programming_language)]`_`f.`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f]

`B100`F9d9trait Speak {`f`b
`B100`F9d9 fn speak(&self);`f`b
`B100`F9d9}`f`b
`B100`F9d9`f`b
`B100`F9d9struct Cat;`f`b
`B100`F9d9`f`b
`B100`F9d9impl Speak for Cat {`f`b
`B100`F9d9 fn speak(&self) {`f`b
`B100`F9d9 println!("Meow!");`f`b
`B100`F9d9 }`f`b
`B100`F9d9}`f`b
`B100`F9d9`f`b
`B100`F9d9fn talk<T: Speak>(pet: T) {`f`b
`B100`F9d9 pet.speak();`f`b
`B100`F9d9}`f`b
`B100`F9d9`f`b
`B100`F9d9fn main() {`f`b
`B100`F9d9 let pet = Cat;`f`b
`B100`F9d9 talk(pet);`f`b
`B100`F9d9}`f`b

Rust will monomorphize this when compiled into:

`B100`F9d9fn talk_cat(pet: Cat) {`f`b
`B100`F9d9 pet.speak();`f`b
`B100`F9d9}`f`b

>>See also

• `F33f`_`[Dynamic dispatch`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Dynamic_dispatch]`_`f

>>References

`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f `*Elements of Clojure`*. Lulu.com. 2019. p. 68. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 9780359360581. Retrieved 17 July 2022.
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f "Generic Data Types - The Rust Programming Language". `*doc.rust-lang.org`*.

• https://developer.apple.com/swift/blog/?id=27

`c`F0af`_`[↑ Back to top`#top]`_`f`a